from django.contrib.auth.models import User
from django.http import JsonResponse
from django.shortcuts import render

'''
user页面，操作执行用例
'''


def index(request):
    username = request.user.username
    # 通过username查询所有的流程、case
    qs = User.objects.all()
    if len(qs) == 1:
        # 初始化用户
        initUser()

    content = {'username': username}
    return render(request, 'master/index.html', content)


def initUser():
    User.objects.create_user('online', "", "asdf1234")
    User.objects.create_user('dev03', "", "asdf1234")


def run(request):
    print(request.user.username)

    return JsonResponse({'status': True, 'url': 'https://baidu.com'})
